<?php 
	$pPageIsPublic = false;
	include '../_common.php';
	$_SESSION["m1"]="destination";
	$_SESSION["m2"]="continent-list";
?>
<?php include("header.php"); ?>
<script type="text/javascript">
$().ready(function(){
	$('#select-all').checkedToggle('ul#listin');
	
	$('#del').live('click', function(){
		var check = $(this).closest("li").find('input:checkbox');  
		check.attr('checked', true);
		delItemSelected(check);
	});
});

function delItemSelected(btn) {
	var checked = $('ul#listin').find('input:checked');
	
	if (checked.length == 0) {
		Notify('Select a Continent.!',1);
		return false;
	} else {
		var items, li;
		if (btn.id == "checked") {
			items = checked.serialize();
			li = checked.closest("li");
		} else {
			items = $(btn).serialize();
			li = $(btn).closest("li");
		}
		
		items = decodeURIComponent(items);
		
		if (! confirm("You going to delete "+ li.length +" Continent"+ (li.length > 1 ? "s" : "")    +"?")){
			return false;
		} else {
			var conf = "After being removed, the following will take place:\n";
			$(li).find('input[type="hidden"].history').each(function(){
				conf += $(this).val() + "\n";
			});
			conf += "---------------------------\n";
			conf += "No continent is available";
			
			if (! confirm(conf)){
				return false;
			} else {
				ajaxAdmin({
					data: items + "&action=item-delete&class=continent",
					success: function(response) {
						if (response) {
							Notify(response, 0);
							li.fadeOut(300, function(){$(this).remove();});
						}	
					}
				});
			}
		}					
	}
}
</script>
<?php include("sidebar.php"); ?>
<div id="list">
<h2>Continent List</h2>
<ul id="subnav">
 	<li class="noleft" ><input type="checkbox" name="select-all" id="select-all" /><label for="select-all" class="first-check" >Select All</label></li>
	<li ><a href="javascript:void(0);" id="checked" onclick="delItemSelected(this)"  >Delete Selection</a></li>
	<li class="noborder" > <a href="continent-add.php" class="add"> Add a New Continent</a></li>
</ul>

<table id="gradient-style" >
	<thead>
		<tr>
    		<th width="85%" >Continent</th>
    		<th width="15%" >Action</th>
  		</tr>
	</thead>
</table>
<ul id="listin" >
<?php
$objCont = new Continent();
$objCont ->loadItems("#title ASC", "#status like '".$chkstatus."%'");
while($objItem = $objCont ->rNext()):
?>	
	<li id="recordsArray_<?php echo $objItem->id; ?>"><table id="gradient-style">
		<tr>
			<td width="4%" ><input type="checkbox" name="items[]" value="<?php echo $objItem->id;?>"   />
			<select style="display: none; visibility: hidden;" class="history" >
				<option value="Continent"  ><?php echo $objItem ->title ?> </option>
				<option value="Number of Countries"  ><?php echo $objItem ->getCountOfCountries() ?> </option>
			</select>
			
			<input type="hidden" class="history" value="<?php echo $objItem ->title ?> : <?php echo $objItem ->getCountOfCountries()." countr". ($objItem ->getCountOfCountries() > 1 ? "ies" : "y")  ?>"> 
			
			
			</td>
    		<td width="81%"  ><strong><?php echo $objItem ->title  ?></strong><br/>
	    		<strong class="note-small" >status: </strong><?php echo $objItem ->status  ?><br/>
    		</td>
    		<td width="15%" >
    			<table>
				  <tr>
				    <td>
				    	<p class="subnav">
	    					<a href="continent-add.php?id=<?php echo $objItem ->id ?>" > edit  </a>
	    					<a href="javascript:void(0)" id="del" > delete  </a>
	    				</p>
				    </td>
				  </tr>
				</table>    		
    		</td>
  		</tr></table>
  	</li>
<?php endwhile;  ?>  		
</ul>
</div>
<div class="clear"></div>    
<?php include("footer.php"); ?>